﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BUSINESS_OBJECT;

namespace CRM.customer
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        PAYMENTcls pymt = new PAYMENTcls();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) 

            {
                DataTable dt =pymt.GetRecords (-99,"", -99, Convert.ToDateTime("1-1-1800"), false, " and ");
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
        }
                   
        protected void Button1_Click(object sender, EventArgs e)
        {
            pymt.ID = -99;
            pymt.COMPANY_NAME = Txtname.Text;
            pymt.PAYMENT = Convert.ToInt64(Txtpaymnt.Text);
            pymt.DATE =Convert.ToDateTime(Txtdate.Text);
            pymt.ISDELETED = false;
            pymt.SaveRecords();
            Response.Redirect("payment.aspx");

        }

        protected void btEdit_Command(object sender, CommandEventArgs e)
        {
            DataTable dt = pymt.GetRecords(Convert.ToInt64(e.CommandArgument.ToString()), "", -99, Convert.ToDateTime("1/1/1800"), false, " and ");
            txtid.Text = dt.Rows[0]["ID"].ToString();
            Txtname.Text=dt.Rows[0]["COMPANY_NAME"].ToString();
            Txtpaymnt.Text = dt.Rows[0]["PAYMENT"].ToString();
            Txtdate.Text = dt.Rows[0]["DATE"].ToString();


        }

        protected void btDelete_Command(object sender, CommandEventArgs e)
        {
            DataTable dt =pymt.GetRecords(Convert.ToInt64(e.CommandArgument.ToString()), "", -99, Convert.ToDateTime("1/1/1800"), false, " and ");
            pymt.ID = Convert.ToInt64(e.CommandArgument.ToString());
            pymt.COMPANY_NAME = dt.Rows[0]["COMPANY_NAME"].ToString();
            pymt.PAYMENT=Convert.ToInt64(dt.Rows[0]["PAYMENT"].ToString());
            pymt.DATE = Convert.ToDateTime(dt.Rows[0]["DATE"].ToString());
            pymt.ISDELETED = true;
            pymt.SaveRecords();
            Response.Redirect("payment.aspx");

            

        }

        protected void BTUPDATE_Click(object sender, EventArgs e)
        {
            pymt.ID = Convert.ToInt64(txtid.Text);
            pymt.COMPANY_NAME = Txtname.Text;
            pymt.PAYMENT = Convert.ToInt64(Txtpaymnt.Text);
            pymt.DATE=Convert.ToDateTime(Txtdate.Text);
            pymt.ISDELETED = false;
            pymt.SaveRecords();
            Response.Redirect("payment.aspx");


        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

        }
    }
}
